{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "* https://demo.allennlp.org/sentiment-analysis/MjI4MTQzNw==\n",
    "* https://github.com/allenai/allennlp/tree/master/allennlp/interpret/saliency_interpreters\n",
    "* https://github.com/allenai/allennlp/blob/master/allennlp/interpret/saliency_interpreters/simple_gradient.py"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "!python --version"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "!pip uninstall -y allennlp\n",
    "!pip uninstall -y allennlp-models\n",
    "!pip uninstall -y enum34"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Collecting git+https://github.com/allenai/allennlp-models.git@6a81154dc1df37131dde1e8ba734df0fdf1cfb92\n",
      "  Cloning https://github.com/allenai/allennlp-models.git (to revision 6a81154dc1df37131dde1e8ba734df0fdf1cfb92) to /tmp/pip-req-build-5vfc79np\n",
      "  Installing build dependencies ... \u001b[?25ldone\n",
      "\u001b[?25h  Getting requirements to build wheel ... \u001b[?25ldone\n",
      "\u001b[?25h    Preparing wheel metadata ... \u001b[?25ldone\n",
      "\u001b[?25hRequirement already satisfied: word2number>=1.1 in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from allennlp-models==1.2.0) (1.1)\n",
      "Requirement already satisfied: nltk in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from allennlp-models==1.2.0) (3.4.5)\n",
      "Requirement already satisfied: conllu==4.2.1 in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from allennlp-models==1.2.0) (4.2.1)\n",
      "Requirement already satisfied: ftfy in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from allennlp-models==1.2.0) (5.8)\n",
      "Collecting allennlp@ git+https://github.com/allenai/allennlp.git@master\n",
      "  Cloning https://github.com/allenai/allennlp.git (to revision master) to /tmp/pip-install-lo51xgn8/allennlp\n",
      "  Installing build dependencies ... \u001b[?25ldone\n",
      "\u001b[?25h  Getting requirements to build wheel ... \u001b[?25ldone\n",
      "\u001b[?25h    Preparing wheel metadata ... \u001b[?25ldone\n",
      "\u001b[?25hRequirement already satisfied: py-rouge==1.1 in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from allennlp-models==1.2.0) (1.1)\n",
      "Requirement already satisfied: six in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from nltk->allennlp-models==1.2.0) (1.14.0)\n",
      "Requirement already satisfied: wcwidth in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from ftfy->allennlp-models==1.2.0) (0.1.8)\n",
      "Requirement already satisfied: spacy<2.4,>=2.1.0 in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from allennlp@ git+https://github.com/allenai/allennlp.git@master->allennlp-models==1.2.0) (2.2.4)\n",
      "Requirement already satisfied: jsonnet>=0.10.0; sys_platform != \"win32\" in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from allennlp@ git+https://github.com/allenai/allennlp.git@master->allennlp-models==1.2.0) (0.16.0)\n",
      "Requirement already satisfied: tqdm>=4.19 in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from allennlp@ git+https://github.com/allenai/allennlp.git@master->allennlp-models==1.2.0) (4.42.1)\n",
      "Requirement already satisfied: numpy in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from allennlp@ git+https://github.com/allenai/allennlp.git@master->allennlp-models==1.2.0) (1.18.1)\n",
      "Requirement already satisfied: filelock<3.1,>=3.0 in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from allennlp@ git+https://github.com/allenai/allennlp.git@master->allennlp-models==1.2.0) (3.0.12)\n",
      "Requirement already satisfied: torch<1.8.0,>=1.6.0 in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from allennlp@ git+https://github.com/allenai/allennlp.git@master->allennlp-models==1.2.0) (1.6.0)\n",
      "Requirement already satisfied: scipy in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from allennlp@ git+https://github.com/allenai/allennlp.git@master->allennlp-models==1.2.0) (1.4.1)\n",
      "Requirement already satisfied: pytest in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from allennlp@ git+https://github.com/allenai/allennlp.git@master->allennlp-models==1.2.0) (5.3.5)\n",
      "Requirement already satisfied: overrides==3.1.0 in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from allennlp@ git+https://github.com/allenai/allennlp.git@master->allennlp-models==1.2.0) (3.1.0)\n",
      "Requirement already satisfied: tensorboardX>=1.2 in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from allennlp@ git+https://github.com/allenai/allennlp.git@master->allennlp-models==1.2.0) (2.1)\n",
      "Requirement already satisfied: boto3<2.0,>=1.14 in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from allennlp@ git+https://github.com/allenai/allennlp.git@master->allennlp-models==1.2.0) (1.14.60)\n",
      "Requirement already satisfied: requests>=2.18 in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from allennlp@ git+https://github.com/allenai/allennlp.git@master->allennlp-models==1.2.0) (2.22.0)\n",
      "Requirement already satisfied: dataclasses; python_version < \"3.7\" in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from allennlp@ git+https://github.com/allenai/allennlp.git@master->allennlp-models==1.2.0) (0.7)\n",
      "Requirement already satisfied: jsonpickle in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from allennlp@ git+https://github.com/allenai/allennlp.git@master->allennlp-models==1.2.0) (1.4.1)\n",
      "Requirement already satisfied: transformers<3.5,>=3.1 in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from allennlp@ git+https://github.com/allenai/allennlp.git@master->allennlp-models==1.2.0) (3.4.0)\n",
      "Requirement already satisfied: scikit-learn in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from allennlp@ git+https://github.com/allenai/allennlp.git@master->allennlp-models==1.2.0) (0.23.1)\n",
      "Requirement already satisfied: h5py in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from allennlp@ git+https://github.com/allenai/allennlp.git@master->allennlp-models==1.2.0) (2.10.0)\n",
      "Requirement already satisfied: srsly<1.1.0,>=1.0.2 in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from spacy<2.4,>=2.1.0->allennlp@ git+https://github.com/allenai/allennlp.git@master->allennlp-models==1.2.0) (1.0.3)\n",
      "Requirement already satisfied: catalogue<1.1.0,>=0.0.7 in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from spacy<2.4,>=2.1.0->allennlp@ git+https://github.com/allenai/allennlp.git@master->allennlp-models==1.2.0) (1.0.0)\n",
      "Requirement already satisfied: blis<0.5.0,>=0.4.0 in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from spacy<2.4,>=2.1.0->allennlp@ git+https://github.com/allenai/allennlp.git@master->allennlp-models==1.2.0) (0.4.1)\n",
      "Requirement already satisfied: cymem<2.1.0,>=2.0.2 in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from spacy<2.4,>=2.1.0->allennlp@ git+https://github.com/allenai/allennlp.git@master->allennlp-models==1.2.0) (2.0.4)\n",
      "Requirement already satisfied: murmurhash<1.1.0,>=0.28.0 in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from spacy<2.4,>=2.1.0->allennlp@ git+https://github.com/allenai/allennlp.git@master->allennlp-models==1.2.0) (1.0.4)\n",
      "Requirement already satisfied: setuptools in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from spacy<2.4,>=2.1.0->allennlp@ git+https://github.com/allenai/allennlp.git@master->allennlp-models==1.2.0) (45.2.0.post20200210)\n",
      "Requirement already satisfied: plac<1.2.0,>=0.9.6 in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from spacy<2.4,>=2.1.0->allennlp@ git+https://github.com/allenai/allennlp.git@master->allennlp-models==1.2.0) (1.1.3)\n",
      "Requirement already satisfied: preshed<3.1.0,>=3.0.2 in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from spacy<2.4,>=2.1.0->allennlp@ git+https://github.com/allenai/allennlp.git@master->allennlp-models==1.2.0) (3.0.4)\n",
      "Requirement already satisfied: wasabi<1.1.0,>=0.4.0 in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from spacy<2.4,>=2.1.0->allennlp@ git+https://github.com/allenai/allennlp.git@master->allennlp-models==1.2.0) (0.8.0)\n",
      "Requirement already satisfied: thinc==7.4.0 in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from spacy<2.4,>=2.1.0->allennlp@ git+https://github.com/allenai/allennlp.git@master->allennlp-models==1.2.0) (7.4.0)\n",
      "Requirement already satisfied: future in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from torch<1.8.0,>=1.6.0->allennlp@ git+https://github.com/allenai/allennlp.git@master->allennlp-models==1.2.0) (0.18.2)\n",
      "Requirement already satisfied: py>=1.5.0 in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from pytest->allennlp@ git+https://github.com/allenai/allennlp.git@master->allennlp-models==1.2.0) (1.8.1)\n",
      "Requirement already satisfied: packaging in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from pytest->allennlp@ git+https://github.com/allenai/allennlp.git@master->allennlp-models==1.2.0) (20.1)\n",
      "Requirement already satisfied: attrs>=17.4.0 in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from pytest->allennlp@ git+https://github.com/allenai/allennlp.git@master->allennlp-models==1.2.0) (19.3.0)\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Requirement already satisfied: more-itertools>=4.0.0 in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from pytest->allennlp@ git+https://github.com/allenai/allennlp.git@master->allennlp-models==1.2.0) (8.2.0)\n",
      "Requirement already satisfied: pluggy<1.0,>=0.12 in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from pytest->allennlp@ git+https://github.com/allenai/allennlp.git@master->allennlp-models==1.2.0) (0.13.1)\n",
      "Requirement already satisfied: importlib-metadata>=0.12 in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from pytest->allennlp@ git+https://github.com/allenai/allennlp.git@master->allennlp-models==1.2.0) (1.5.0)\n",
      "Requirement already satisfied: protobuf>=3.8.0 in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from tensorboardX>=1.2->allennlp@ git+https://github.com/allenai/allennlp.git@master->allennlp-models==1.2.0) (3.11.4)\n",
      "Requirement already satisfied: jmespath<1.0.0,>=0.7.1 in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from boto3<2.0,>=1.14->allennlp@ git+https://github.com/allenai/allennlp.git@master->allennlp-models==1.2.0) (0.10.0)\n",
      "Requirement already satisfied: botocore<1.18.0,>=1.17.60 in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from boto3<2.0,>=1.14->allennlp@ git+https://github.com/allenai/allennlp.git@master->allennlp-models==1.2.0) (1.17.60)\n",
      "Requirement already satisfied: s3transfer<0.4.0,>=0.3.0 in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from boto3<2.0,>=1.14->allennlp@ git+https://github.com/allenai/allennlp.git@master->allennlp-models==1.2.0) (0.3.3)\n",
      "Requirement already satisfied: certifi>=2017.4.17 in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from requests>=2.18->allennlp@ git+https://github.com/allenai/allennlp.git@master->allennlp-models==1.2.0) (2020.6.20)\n",
      "Requirement already satisfied: chardet<3.1.0,>=3.0.2 in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from requests>=2.18->allennlp@ git+https://github.com/allenai/allennlp.git@master->allennlp-models==1.2.0) (3.0.4)\n",
      "Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from requests>=2.18->allennlp@ git+https://github.com/allenai/allennlp.git@master->allennlp-models==1.2.0) (1.25.10)\n",
      "Requirement already satisfied: idna<2.9,>=2.5 in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from requests>=2.18->allennlp@ git+https://github.com/allenai/allennlp.git@master->allennlp-models==1.2.0) (2.8)\n",
      "Requirement already satisfied: sacremoses in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from transformers<3.5,>=3.1->allennlp@ git+https://github.com/allenai/allennlp.git@master->allennlp-models==1.2.0) (0.0.43)\n",
      "Requirement already satisfied: sentencepiece!=0.1.92 in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from transformers<3.5,>=3.1->allennlp@ git+https://github.com/allenai/allennlp.git@master->allennlp-models==1.2.0) (0.1.94)\n",
      "Requirement already satisfied: tokenizers==0.9.2 in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from transformers<3.5,>=3.1->allennlp@ git+https://github.com/allenai/allennlp.git@master->allennlp-models==1.2.0) (0.9.2)\n",
      "Requirement already satisfied: regex!=2019.12.17 in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from transformers<3.5,>=3.1->allennlp@ git+https://github.com/allenai/allennlp.git@master->allennlp-models==1.2.0) (2020.10.28)\n",
      "Requirement already satisfied: joblib>=0.11 in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from scikit-learn->allennlp@ git+https://github.com/allenai/allennlp.git@master->allennlp-models==1.2.0) (0.14.1)\n",
      "Requirement already satisfied: threadpoolctl>=2.0.0 in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from scikit-learn->allennlp@ git+https://github.com/allenai/allennlp.git@master->allennlp-models==1.2.0) (2.1.0)\n",
      "Requirement already satisfied: pyparsing>=2.0.2 in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from packaging->pytest->allennlp@ git+https://github.com/allenai/allennlp.git@master->allennlp-models==1.2.0) (2.4.6)\n",
      "Requirement already satisfied: zipp>=0.5 in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from importlib-metadata>=0.12->pytest->allennlp@ git+https://github.com/allenai/allennlp.git@master->allennlp-models==1.2.0) (2.2.0)\n",
      "Requirement already satisfied: python-dateutil<3.0.0,>=2.1 in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from botocore<1.18.0,>=1.17.60->boto3<2.0,>=1.14->allennlp@ git+https://github.com/allenai/allennlp.git@master->allennlp-models==1.2.0) (2.8.1)\n",
      "Requirement already satisfied: docutils<0.16,>=0.10 in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from botocore<1.18.0,>=1.17.60->boto3<2.0,>=1.14->allennlp@ git+https://github.com/allenai/allennlp.git@master->allennlp-models==1.2.0) (0.15.2)\n",
      "Requirement already satisfied: click in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from sacremoses->transformers<3.5,>=3.1->allennlp@ git+https://github.com/allenai/allennlp.git@master->allennlp-models==1.2.0) (7.0)\n",
      "Building wheels for collected packages: allennlp-models, allennlp\n",
      "  Building wheel for allennlp-models (PEP 517) ... \u001b[?25ldone\n",
      "\u001b[?25h  Created wheel for allennlp-models: filename=allennlp_models-1.2.0-py3-none-any.whl size=342128 sha256=ede0f09abde9ca294b8da971651d0716149a00bd91b909b64099553ded90e626\n",
      "  Stored in directory: /home/ec2-user/.cache/pip/wheels/b8/f5/3a/b866e3e358b225c68fa4028de88451d739547329500ebdc523\n",
      "  Building wheel for allennlp (PEP 517) ... \u001b[?25ldone\n",
      "\u001b[?25h  Created wheel for allennlp: filename=allennlp-1.2.0-py3-none-any.whl size=500795 sha256=c904c126ea29c38d9a7a1cfbf189be4dedff8e1f4dfae3e7814f0e51713d1afd\n",
      "  Stored in directory: /tmp/pip-ephem-wheel-cache-h4wbsmya/wheels/4f/31/cc/283226e9be9504e3ef0cb77695fc0262763b5654ad0b59353a\n",
      "Successfully built allennlp-models allennlp\n",
      "Installing collected packages: allennlp, allennlp-models\n",
      "Successfully installed allennlp-1.2.0 allennlp-models-1.2.0\n"
     ]
    }
   ],
   "source": [
    "!pip install git+https://github.com/allenai/allennlp-models.git@6a81154dc1df37131dde1e8ba734df0fdf1cfb92"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Collecting git+https://github.com/allenai/allennlp.git@92a844a7b1d99839428f4e3e3302f27c2f06bc7f\n",
      "  Cloning https://github.com/allenai/allennlp.git (to revision 92a844a7b1d99839428f4e3e3302f27c2f06bc7f) to /tmp/pip-req-build-b90vhz9r\n",
      "  Installing build dependencies ... \u001b[?25ldone\n",
      "\u001b[?25h  Getting requirements to build wheel ... \u001b[?25ldone\n",
      "\u001b[?25h    Preparing wheel metadata ... \u001b[?25ldone\n",
      "\u001b[?25hRequirement already satisfied (use --upgrade to upgrade): allennlp==1.2.0 from git+https://github.com/allenai/allennlp.git@92a844a7b1d99839428f4e3e3302f27c2f06bc7f in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages\n",
      "Requirement already satisfied: dataclasses; python_version < \"3.7\" in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from allennlp==1.2.0) (0.7)\n",
      "Requirement already satisfied: scipy in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from allennlp==1.2.0) (1.4.1)\n",
      "Requirement already satisfied: numpy in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from allennlp==1.2.0) (1.18.1)\n",
      "Requirement already satisfied: pytest in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from allennlp==1.2.0) (5.3.5)\n",
      "Requirement already satisfied: overrides==3.1.0 in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from allennlp==1.2.0) (3.1.0)\n",
      "Requirement already satisfied: requests>=2.18 in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from allennlp==1.2.0) (2.22.0)\n",
      "Requirement already satisfied: spacy<2.4,>=2.1.0 in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from allennlp==1.2.0) (2.2.4)\n",
      "Requirement already satisfied: jsonnet>=0.10.0; sys_platform != \"win32\" in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from allennlp==1.2.0) (0.16.0)\n",
      "Requirement already satisfied: scikit-learn in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from allennlp==1.2.0) (0.23.1)\n",
      "Requirement already satisfied: nltk in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from allennlp==1.2.0) (3.4.5)\n",
      "Requirement already satisfied: tqdm>=4.19 in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from allennlp==1.2.0) (4.42.1)\n",
      "Requirement already satisfied: jsonpickle in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from allennlp==1.2.0) (1.4.1)\n",
      "Requirement already satisfied: boto3<2.0,>=1.14 in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from allennlp==1.2.0) (1.14.60)\n",
      "Requirement already satisfied: transformers<3.5,>=3.1 in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from allennlp==1.2.0) (3.4.0)\n",
      "Requirement already satisfied: torch<1.8.0,>=1.6.0 in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from allennlp==1.2.0) (1.6.0)\n",
      "Requirement already satisfied: filelock<3.1,>=3.0 in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from allennlp==1.2.0) (3.0.12)\n",
      "Requirement already satisfied: h5py in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from allennlp==1.2.0) (2.10.0)\n",
      "Requirement already satisfied: tensorboardX>=1.2 in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from allennlp==1.2.0) (2.1)\n",
      "Requirement already satisfied: py>=1.5.0 in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from pytest->allennlp==1.2.0) (1.8.1)\n",
      "Requirement already satisfied: packaging in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from pytest->allennlp==1.2.0) (20.1)\n",
      "Requirement already satisfied: attrs>=17.4.0 in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from pytest->allennlp==1.2.0) (19.3.0)\n",
      "Requirement already satisfied: more-itertools>=4.0.0 in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from pytest->allennlp==1.2.0) (8.2.0)\n",
      "Requirement already satisfied: pluggy<1.0,>=0.12 in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from pytest->allennlp==1.2.0) (0.13.1)\n",
      "Requirement already satisfied: wcwidth in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from pytest->allennlp==1.2.0) (0.1.8)\n",
      "Requirement already satisfied: importlib-metadata>=0.12 in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from pytest->allennlp==1.2.0) (1.5.0)\n",
      "Requirement already satisfied: certifi>=2017.4.17 in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from requests>=2.18->allennlp==1.2.0) (2020.6.20)\n",
      "Requirement already satisfied: chardet<3.1.0,>=3.0.2 in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from requests>=2.18->allennlp==1.2.0) (3.0.4)\n",
      "Requirement already satisfied: idna<2.9,>=2.5 in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from requests>=2.18->allennlp==1.2.0) (2.8)\n",
      "Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from requests>=2.18->allennlp==1.2.0) (1.25.10)\n",
      "Requirement already satisfied: blis<0.5.0,>=0.4.0 in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from spacy<2.4,>=2.1.0->allennlp==1.2.0) (0.4.1)\n",
      "Requirement already satisfied: srsly<1.1.0,>=1.0.2 in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from spacy<2.4,>=2.1.0->allennlp==1.2.0) (1.0.3)\n",
      "Requirement already satisfied: preshed<3.1.0,>=3.0.2 in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from spacy<2.4,>=2.1.0->allennlp==1.2.0) (3.0.4)\n",
      "Requirement already satisfied: setuptools in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from spacy<2.4,>=2.1.0->allennlp==1.2.0) (45.2.0.post20200210)\n",
      "Requirement already satisfied: wasabi<1.1.0,>=0.4.0 in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from spacy<2.4,>=2.1.0->allennlp==1.2.0) (0.8.0)\n",
      "Requirement already satisfied: catalogue<1.1.0,>=0.0.7 in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from spacy<2.4,>=2.1.0->allennlp==1.2.0) (1.0.0)\n",
      "Requirement already satisfied: murmurhash<1.1.0,>=0.28.0 in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from spacy<2.4,>=2.1.0->allennlp==1.2.0) (1.0.4)\n",
      "Requirement already satisfied: cymem<2.1.0,>=2.0.2 in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from spacy<2.4,>=2.1.0->allennlp==1.2.0) (2.0.4)\n",
      "Requirement already satisfied: plac<1.2.0,>=0.9.6 in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from spacy<2.4,>=2.1.0->allennlp==1.2.0) (1.1.3)\n",
      "Requirement already satisfied: thinc==7.4.0 in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from spacy<2.4,>=2.1.0->allennlp==1.2.0) (7.4.0)\n",
      "Requirement already satisfied: joblib>=0.11 in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from scikit-learn->allennlp==1.2.0) (0.14.1)\n",
      "Requirement already satisfied: threadpoolctl>=2.0.0 in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from scikit-learn->allennlp==1.2.0) (2.1.0)\n",
      "Requirement already satisfied: six in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from nltk->allennlp==1.2.0) (1.14.0)\n",
      "Requirement already satisfied: jmespath<1.0.0,>=0.7.1 in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from boto3<2.0,>=1.14->allennlp==1.2.0) (0.10.0)\n",
      "Requirement already satisfied: botocore<1.18.0,>=1.17.60 in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from boto3<2.0,>=1.14->allennlp==1.2.0) (1.17.60)\n",
      "Requirement already satisfied: s3transfer<0.4.0,>=0.3.0 in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from boto3<2.0,>=1.14->allennlp==1.2.0) (0.3.3)\n",
      "Requirement already satisfied: sacremoses in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from transformers<3.5,>=3.1->allennlp==1.2.0) (0.0.43)\n",
      "Requirement already satisfied: tokenizers==0.9.2 in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from transformers<3.5,>=3.1->allennlp==1.2.0) (0.9.2)\n",
      "Requirement already satisfied: sentencepiece!=0.1.92 in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from transformers<3.5,>=3.1->allennlp==1.2.0) (0.1.94)\n",
      "Requirement already satisfied: protobuf in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from transformers<3.5,>=3.1->allennlp==1.2.0) (3.11.4)\n",
      "Requirement already satisfied: regex!=2019.12.17 in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from transformers<3.5,>=3.1->allennlp==1.2.0) (2020.10.28)\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Requirement already satisfied: future in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from torch<1.8.0,>=1.6.0->allennlp==1.2.0) (0.18.2)\n",
      "Requirement already satisfied: pyparsing>=2.0.2 in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from packaging->pytest->allennlp==1.2.0) (2.4.6)\n",
      "Requirement already satisfied: zipp>=0.5 in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from importlib-metadata>=0.12->pytest->allennlp==1.2.0) (2.2.0)\n",
      "Requirement already satisfied: python-dateutil<3.0.0,>=2.1 in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from botocore<1.18.0,>=1.17.60->boto3<2.0,>=1.14->allennlp==1.2.0) (2.8.1)\n",
      "Requirement already satisfied: docutils<0.16,>=0.10 in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from botocore<1.18.0,>=1.17.60->boto3<2.0,>=1.14->allennlp==1.2.0) (0.15.2)\n",
      "Requirement already satisfied: click in /home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages (from sacremoses->transformers<3.5,>=3.1->allennlp==1.2.0) (7.0)\n",
      "Building wheels for collected packages: allennlp\n",
      "  Building wheel for allennlp (PEP 517) ... \u001b[?25ldone\n",
      "\u001b[?25h  Created wheel for allennlp: filename=allennlp-1.2.0-py3-none-any.whl size=500795 sha256=56f82eed89208d89c2c50644776d44602a58a578381cbb4bc161c14e8b93769f\n",
      "  Stored in directory: /home/ec2-user/.cache/pip/wheels/23/63/bd/cda823525f56c922bee55fe838039df00aa2f09fae87a3687b\n",
      "Successfully built allennlp\n"
     ]
    }
   ],
   "source": [
    "!pip install git+https://github.com/allenai/allennlp.git@92a844a7b1d99839428f4e3e3302f27c2f06bc7f"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Package                            Version\r\n",
      "---------------------------------- -------------------\r\n",
      "absl-py                            0.11.0\r\n",
      "alabaster                          0.7.12\r\n",
      "allennlp                           1.2.0\r\n",
      "allennlp-models                    1.2.0\r\n",
      "anaconda-client                    1.7.2\r\n",
      "anaconda-project                   0.8.3\r\n",
      "argh                               0.26.2\r\n",
      "asn1crypto                         1.3.0\r\n",
      "astor                              0.8.1\r\n",
      "astroid                            2.4.2\r\n",
      "astropy                            4.0\r\n",
      "astunparse                         1.6.3\r\n",
      "atomicwrites                       1.3.0\r\n",
      "attrs                              19.3.0\r\n",
      "Automat                            20.2.0\r\n",
      "autopep8                           1.4.4\r\n",
      "autovizwidget                      0.16.0\r\n",
      "awscli                             1.18.137\r\n",
      "awswrangler                        1.9.3\r\n",
      "Babel                              2.8.0\r\n",
      "backcall                           0.1.0\r\n",
      "backports.shutil-get-terminal-size 1.0.0\r\n",
      "bcrypt                             3.2.0\r\n",
      "beautifulsoup4                     4.8.2\r\n",
      "bitarray                           1.2.1\r\n",
      "bkcharts                           0.2\r\n",
      "bleach                             3.2.1\r\n",
      "blis                               0.4.1\r\n",
      "bokeh                              1.4.0\r\n",
      "boto                               2.49.0\r\n",
      "boto3                              1.14.60\r\n",
      "botocore                           1.17.60\r\n",
      "Bottleneck                         1.3.2\r\n",
      "cached-property                    1.5.2\r\n",
      "cachetools                         4.1.1\r\n",
      "catalogue                          1.0.0\r\n",
      "certifi                            2020.6.20\r\n",
      "cffi                               1.14.0\r\n",
      "chardet                            3.0.4\r\n",
      "Click                              7.0\r\n",
      "cloudpickle                        1.3.0\r\n",
      "clyent                             1.2.2\r\n",
      "colorama                           0.4.3\r\n",
      "conllu                             4.2.1\r\n",
      "contextlib2                        0.6.0.post1\r\n",
      "cryptography                       2.8\r\n",
      "cycler                             0.10.0\r\n",
      "cymem                              2.0.4\r\n",
      "Cython                             0.29.15\r\n",
      "cytoolz                            0.10.1\r\n",
      "dask                               2.11.0\r\n",
      "dataclasses                        0.7\r\n",
      "decorator                          4.4.1\r\n",
      "defusedxml                         0.6.0\r\n",
      "diff-match-patch                   20181111\r\n",
      "dill                               0.3.2\r\n",
      "distributed                        2.11.0\r\n",
      "distro                             1.5.0\r\n",
      "dm-tree                            0.1.5\r\n",
      "docker                             4.3.1\r\n",
      "docker-compose                     1.27.4\r\n",
      "dockerpty                          0.4.1\r\n",
      "docopt                             0.6.2\r\n",
      "docutils                           0.15.2\r\n",
      "en-core-web-sm                     2.2.5\r\n",
      "entrypoints                        0.3\r\n",
      "enum-compat                        0.0.3\r\n",
      "environment-kernels                1.1.1\r\n",
      "et-xmlfile                         1.0.1\r\n",
      "fastcache                          1.1.0\r\n",
      "filelock                           3.0.12\r\n",
      "flake8                             3.7.9\r\n",
      "flaky                              3.7.0\r\n",
      "Flask                              1.1.1\r\n",
      "fsspec                             0.6.2\r\n",
      "ftfy                               5.8\r\n",
      "future                             0.18.2\r\n",
      "gast                               0.3.3\r\n",
      "gevent                             1.4.0\r\n",
      "glob2                              0.7\r\n",
      "gmpy2                              2.0.8\r\n",
      "google-auth                        1.23.0\r\n",
      "google-auth-oauthlib               0.4.2\r\n",
      "google-pasta                       0.2.0\r\n",
      "googleapis-common-protos           1.52.0\r\n",
      "greenlet                           0.4.15\r\n",
      "grpcio                             1.33.2\r\n",
      "h5py                               2.10.0\r\n",
      "hdijupyterutils                    0.16.0\r\n",
      "HeapDict                           1.0.1\r\n",
      "html5lib                           1.0.1\r\n",
      "hypothesis                         5.5.4\r\n",
      "idna                               2.8\r\n",
      "imageio                            2.6.1\r\n",
      "imagesize                          1.2.0\r\n",
      "importlib-metadata                 1.5.0\r\n",
      "importlib-resources                3.3.0\r\n",
      "intervaltree                       3.0.2\r\n",
      "ipykernel                          5.1.4\r\n",
      "ipyparallel                        6.3.0\r\n",
      "ipython                            7.12.0\r\n",
      "ipython-genutils                   0.2.0\r\n",
      "ipywidgets                         7.5.1\r\n",
      "isort                              4.3.21\r\n",
      "itsdangerous                       1.1.0\r\n",
      "jdcal                              1.4.1\r\n",
      "jedi                               0.14.1\r\n",
      "jeepney                            0.4.2\r\n",
      "Jinja2                             2.11.1\r\n",
      "jmespath                           0.10.0\r\n",
      "joblib                             0.14.1\r\n",
      "json5                              0.9.1\r\n",
      "jsonnet                            0.16.0\r\n",
      "jsonpickle                         1.4.1\r\n",
      "jsonschema                         3.2.0\r\n",
      "jupyter                            1.0.0\r\n",
      "jupyter-client                     5.3.4\r\n",
      "jupyter-console                    6.1.0\r\n",
      "jupyter-core                       4.6.1\r\n",
      "jupyterlab                         1.2.6\r\n",
      "jupyterlab-server                  1.0.6\r\n",
      "Keras-Applications                 1.0.8\r\n",
      "Keras-Preprocessing                1.1.2\r\n",
      "keyring                            21.1.0\r\n",
      "kiwisolver                         1.1.0\r\n",
      "lazy-object-proxy                  1.4.3\r\n",
      "libarchive-c                       2.8\r\n",
      "lief                               0.9.0\r\n",
      "llvmlite                           0.31.0\r\n",
      "locket                             0.2.0\r\n",
      "lxml                               4.5.0\r\n",
      "Markdown                           3.3.3\r\n",
      "MarkupSafe                         1.1.1\r\n",
      "matplotlib                         3.2.1\r\n",
      "mccabe                             0.6.1\r\n",
      "mistune                            0.8.4\r\n",
      "mkl-fft                            1.0.15\r\n",
      "mkl-random                         1.1.0\r\n",
      "mkl-service                        2.3.0\r\n",
      "mock                               4.0.1\r\n",
      "more-itertools                     8.2.0\r\n",
      "mpmath                             1.1.0\r\n",
      "msgpack                            0.6.1\r\n",
      "multipledispatch                   0.6.0\r\n",
      "murmurhash                         1.0.4\r\n",
      "nb-conda                           2.2.1\r\n",
      "nb-conda-kernels                   2.2.4\r\n",
      "nbconvert                          5.6.1\r\n",
      "nbformat                           5.0.4\r\n",
      "networkx                           2.4\r\n",
      "nltk                               3.4.5\r\n",
      "nose                               1.3.7\r\n",
      "notebook                           6.0.3\r\n",
      "numba                              0.48.0\r\n",
      "numexpr                            2.7.1\r\n",
      "numpy                              1.18.1\r\n",
      "numpydoc                           0.9.2\r\n",
      "nvidia-ml-py                       10.418.84\r\n",
      "oauthlib                           3.1.0\r\n",
      "olefile                            0.46\r\n",
      "opencv-python                      4.2.0.32\r\n",
      "openpyxl                           3.0.3\r\n",
      "opt-einsum                         3.3.0\r\n",
      "overrides                          3.1.0\r\n",
      "packaging                          20.1\r\n",
      "pandas                             1.0.1\r\n",
      "pandocfilters                      1.4.2\r\n",
      "paramiko                           2.7.2\r\n",
      "parso                              0.5.2\r\n",
      "partd                              1.1.0\r\n",
      "path                               13.1.0\r\n",
      "pathlib2                           2.3.5\r\n",
      "pathtools                          0.1.2\r\n",
      "patsy                              0.5.1\r\n",
      "pep8                               1.7.1\r\n",
      "pexpect                            4.8.0\r\n",
      "pickleshare                        0.7.5\r\n",
      "Pillow                             7.2.0\r\n",
      "pip                                20.2.4\r\n",
      "pkginfo                            1.5.0.1\r\n",
      "plac                               1.1.3\r\n",
      "plotly                             4.11.0\r\n",
      "pluggy                             0.13.1\r\n",
      "ply                                3.11\r\n",
      "preshed                            3.0.4\r\n",
      "prometheus-client                  0.7.1\r\n",
      "promise                            2.3\r\n",
      "prompt-toolkit                     3.0.3\r\n",
      "protobuf                           3.11.4\r\n",
      "protobuf3-to-dict                  0.1.5\r\n",
      "psutil                             5.6.7\r\n",
      "psycopg2                           2.7.5\r\n",
      "psycopg2-binary                    2.8.6\r\n",
      "PTable                             0.9.2\r\n",
      "ptyprocess                         0.6.0\r\n",
      "py                                 1.8.1\r\n",
      "py-rouge                           1.1\r\n",
      "py4j                               0.10.7\r\n",
      "pyarrow                            1.0.1\r\n",
      "pyasn1                             0.4.8\r\n",
      "pyasn1-modules                     0.2.8\r\n",
      "PyAthena                           1.10.7\r\n",
      "pycodestyle                        2.5.0\r\n",
      "pycosat                            0.6.3\r\n",
      "pycparser                          2.19\r\n",
      "pycrypto                           2.6.1\r\n",
      "pycurl                             7.43.0.5\r\n",
      "pydocstyle                         4.0.1\r\n",
      "pyflakes                           2.1.1\r\n",
      "pygal                              2.4.0\r\n",
      "Pygments                           2.5.2\r\n",
      "pykerberos                         1.2.1\r\n",
      "pylint                             2.5.3\r\n",
      "PyMySQL                            0.10.1\r\n",
      "PyNaCl                             1.4.0\r\n",
      "pyodbc                             4.0.0-unsupported\r\n",
      "pyOpenSSL                          19.1.0\r\n",
      "pyparsing                          2.4.6\r\n",
      "pyrsistent                         0.15.7\r\n",
      "PySocks                            1.7.1\r\n",
      "pyspark                            2.3.4\r\n",
      "pytest                             5.3.5\r\n",
      "pytest-arraydiff                   0.3\r\n",
      "pytest-astropy                     0.8.0\r\n",
      "pytest-astropy-header              0.1.2\r\n",
      "pytest-doctestplus                 0.5.0\r\n",
      "pytest-openfiles                   0.4.0\r\n",
      "pytest-remotedata                  0.3.2\r\n",
      "python-dateutil                    2.8.1\r\n",
      "python-dotenv                      0.14.0\r\n",
      "python-jsonrpc-server              0.3.4\r\n",
      "python-language-server             0.31.7\r\n",
      "pytz                               2019.3\r\n",
      "PyWavelets                         1.1.1\r\n",
      "pyxdg                              0.26\r\n",
      "PyYAML                             5.3.1\r\n",
      "pyzmq                              18.1.1\r\n",
      "QDarkStyle                         2.8\r\n",
      "QtAwesome                          0.6.1\r\n",
      "qtconsole                          4.6.0\r\n",
      "QtPy                               1.9.0\r\n",
      "regex                              2020.10.28\r\n",
      "requests                           2.22.0\r\n",
      "requests-kerberos                  0.12.0\r\n",
      "requests-oauthlib                  1.3.0\r\n",
      "responses                          0.12.0\r\n",
      "retrying                           1.3.3\r\n",
      "rope                               0.16.0\r\n",
      "rsa                                4.5\r\n",
      "Rtree                              0.9.3\r\n",
      "ruamel-yaml                        0.15.87\r\n",
      "s3fs                               0.4.2\r\n",
      "s3transfer                         0.3.3\r\n",
      "sacremoses                         0.0.43\r\n",
      "sagemaker                          2.9.2\r\n",
      "sagemaker-experiments              0.1.24\r\n",
      "sagemaker-pyspark                  1.4.1\r\n",
      "sagemaker-tensorflow               2.3.0.1.0.0\r\n",
      "scikit-image                       0.16.2\r\n",
      "scikit-learn                       0.23.1\r\n",
      "scipy                              1.4.1\r\n",
      "seaborn                            0.10.0\r\n",
      "SecretStorage                      3.1.2\r\n",
      "semantic-version                   2.8.5\r\n",
      "Send2Trash                         1.5.0\r\n",
      "sentencepiece                      0.1.94\r\n",
      "setuptools                         45.2.0.post20200210\r\n",
      "simplegeneric                      0.8.1\r\n",
      "singledispatch                     3.4.0.3\r\n",
      "six                                1.14.0\r\n",
      "smdebug                            0.9.3\r\n",
      "smdebug-rulesconfig                0.1.5\r\n",
      "snowballstemmer                    2.0.0\r\n",
      "sortedcollections                  1.1.2\r\n",
      "sortedcontainers                   2.1.0\r\n",
      "soupsieve                          1.9.5\r\n",
      "spacy                              2.2.4\r\n",
      "sparkmagic                         0.15.0\r\n",
      "Sphinx                             3.0.4\r\n",
      "sphinxcontrib-applehelp            1.0.1\r\n",
      "sphinxcontrib-devhelp              1.0.1\r\n",
      "sphinxcontrib-htmlhelp             1.0.2\r\n",
      "sphinxcontrib-jsmath               1.0.1\r\n",
      "sphinxcontrib-qthelp               1.0.2\r\n",
      "sphinxcontrib-serializinghtml      1.1.3\r\n",
      "sphinxcontrib-websupport           1.2.0\r\n",
      "spyder                             4.0.1\r\n",
      "spyder-kernels                     1.8.1\r\n",
      "SQLAlchemy                         1.3.13\r\n",
      "sqlalchemy-redshift                0.8.1\r\n",
      "srsly                              1.0.3\r\n",
      "statsmodels                        0.11.0\r\n",
      "stepfunctions                      2.0.0rc1\r\n",
      "sympy                              1.5.1\r\n",
      "tables                             3.6.1\r\n",
      "tblib                              1.6.0\r\n",
      "tenacity                           6.2.0\r\n",
      "tensorboard                        2.3.0\r\n",
      "tensorboard-plugin-wit             1.7.0\r\n",
      "tensorboardX                       2.1\r\n",
      "tensorflow                         2.3.0\r\n",
      "tensorflow-datasets                4.0.0\r\n",
      "tensorflow-estimator               2.3.0\r\n",
      "tensorflow-metadata                0.24.0\r\n",
      "tensorflow-recommenders            0.2.0\r\n",
      "termcolor                          1.1.0\r\n",
      "terminado                          0.8.3\r\n",
      "testpath                           0.4.4\r\n",
      "texttable                          1.6.3\r\n",
      "thinc                              7.4.0\r\n",
      "threadpoolctl                      2.1.0\r\n",
      "tokenizers                         0.9.2\r\n",
      "toml                               0.10.1\r\n",
      "toolz                              0.10.0\r\n",
      "torch                              1.6.0\r\n",
      "torch-model-archiver               0.1.1\r\n",
      "torchserve                         0.1.1\r\n",
      "tornado                            6.0.3\r\n",
      "tqdm                               4.42.1\r\n",
      "traitlets                          4.3.3\r\n",
      "transformers                       3.4.0\r\n",
      "typed-ast                          1.4.1\r\n",
      "typing-extensions                  3.7.4.3\r\n",
      "ujson                              1.35\r\n",
      "unicodecsv                         0.14.1\r\n",
      "urllib3                            1.25.10\r\n",
      "wasabi                             0.8.0\r\n",
      "watchdog                           0.10.2\r\n",
      "wcwidth                            0.1.8\r\n",
      "webencodings                       0.5.1\r\n",
      "websocket-client                   0.57.0\r\n",
      "Werkzeug                           1.0.0\r\n",
      "wheel                              0.34.2\r\n",
      "widgetsnbextension                 3.5.1\r\n",
      "word2number                        1.1\r\n",
      "wrapt                              1.12.1\r\n",
      "wurlitzer                          2.0.0\r\n",
      "xlrd                               1.2.0\r\n",
      "XlsxWriter                         1.2.7\r\n",
      "xlwt                               1.3.0\r\n",
      "yapf                               0.28.0\r\n",
      "zict                               1.0.0\r\n",
      "zipp                               2.2.0\r\n"
     ]
    }
   ],
   "source": [
    "!pip list"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "from allennlp.predictors.predictor import Predictor\n",
    "\n",
    "predictor = Predictor.from_path(\"https://storage.googleapis.com/allennlp-public-models/sst-roberta-large-2020.06.08.tar.gz\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<allennlp.predictors.text_classifier.TextClassifierPredictor object at 0x7fb8b4462400>\n"
     ]
    }
   ],
   "source": [
    "print(predictor)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'label': '1',\n",
      " 'logits': [4.985845565795898, -3.7536513805389404],\n",
      " 'probs': [0.9998399019241333, 0.0001601087424205616],\n",
      " 'token_ids': [0,\n",
      "               102,\n",
      "               5525,\n",
      "               3056,\n",
      "               12,\n",
      "               7078,\n",
      "               6,\n",
      "               18317,\n",
      "               2855,\n",
      "               463,\n",
      "               1342,\n",
      "               2399,\n",
      "               8173,\n",
      "               37587,\n",
      "               4,\n",
      "               2],\n",
      " 'tokens': ['<s>',\n",
      "            'a',\n",
      "            'very',\n",
      "            'well',\n",
      "            '-',\n",
      "            'made',\n",
      "            ',',\n",
      "            'fun',\n",
      "            'ny',\n",
      "            'and',\n",
      "            'ent',\n",
      "            'ert',\n",
      "            'aining',\n",
      "            'picture',\n",
      "            '.',\n",
      "            '</s>']}\n"
     ]
    }
   ],
   "source": [
    "from pprint import pprint\n",
    "\n",
    "sentence = \"a very well-made, funny and entertaining picture.\"\n",
    "\n",
    "response = predictor.predict(\n",
    "    sentence=sentence\n",
    ")\n",
    "\n",
    "pprint(response)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Interpret"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'sentence': 'a very well-made, funny and entertaining picture.'}\n"
     ]
    }
   ],
   "source": [
    "inputs = {\"sentence\": sentence}\n",
    "print(inputs)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Simple Gradient"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "from allennlp.interpret.saliency_interpreters import SimpleGradient\n",
    "\n",
    "simple_gradient_interpreter = SimpleGradient(predictor)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'instance_1': {'grad_input_1': [0.279369560845839,\n",
      "                                 0.0600904935186349,\n",
      "                                 0.15987346870624614,\n",
      "                                 0.1570943687784923,\n",
      "                                 0.08467084570121039,\n",
      "                                 0.10174642009873701,\n",
      "                                 0.006892518284195784,\n",
      "                                 0.014679348240742502,\n",
      "                                 0.041306962003984725,\n",
      "                                 0.07055409182832174,\n",
      "                                 0.023721910808594447]}}\n"
     ]
    }
   ],
   "source": [
    "from pprint import pprint\n",
    "\n",
    "simple_gradient_interpretation = simple_gradient_interpreter.saliency_interpret_from_json(inputs)\n",
    "\n",
    "pprint(simple_gradient_interpretation)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Smooth Gradient"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [],
   "source": [
    "from allennlp.interpret.saliency_interpreters import SmoothGradient\n",
    "\n",
    "smooth_gradient_interpreter = SmoothGradient(predictor)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'instance_1': {'grad_input_1': [0.12429378531073447,\n",
      "                                 0.2711864406779661,\n",
      "                                 0.04519774011299435,\n",
      "                                 0.02824858757062147,\n",
      "                                 0.22598870056497175,\n",
      "                                 0.0,\n",
      "                                 0.1807909604519774,\n",
      "                                 0.011299435028248588,\n",
      "                                 0.022598870056497175,\n",
      "                                 0.0,\n",
      "                                 0.0903954802259887]}}\n"
     ]
    }
   ],
   "source": [
    "from pprint import pprint\n",
    "\n",
    "smooth_gradient_interpretation = smooth_gradient_interpreter.saliency_interpret_from_json(inputs)\n",
    "\n",
    "pprint(smooth_gradient_interpretation)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Integrated Gradient"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [],
   "source": [
    "from allennlp.interpret.saliency_interpreters import IntegratedGradient\n",
    "\n",
    "integrated_gradient_interpreter = IntegratedGradient(predictor)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'instance_1': {'grad_input_1': [0.10338538634781776,\n",
      "                                 0.19893729477254535,\n",
      "                                 0.008472852427212439,\n",
      "                                 0.0005615125409780962,\n",
      "                                 0.01615882936970941,\n",
      "                                 0.19841675479930443,\n",
      "                                 0.06983715792756516,\n",
      "                                 0.02557800239689324,\n",
      "                                 0.06044705677145928,\n",
      "                                 0.16507210055696683,\n",
      "                                 0.1531329783765724]}}\n"
     ]
    }
   ],
   "source": [
    "from pprint import pprint\n",
    "\n",
    "integrated_gradient_interpretation = integrated_gradient_interpreter.saliency_interpret_from_json(inputs)\n",
    "\n",
    "pprint(integrated_gradient_interpretation)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "conda_python3",
   "language": "python",
   "name": "conda_python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
